﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text;
using IDAL.A;
using Model.A;

namespace DAL.A
{
    public class AProgramWriting:BaseRepository_DT<AProgramWritingInfo>,IAProgramWriting 
    {
        #region 静态变量定义
        private const string PARM_APROGRAMWRITING_PCBASN = "@PCBASN";
        private const string PARM_APROGRAMWRITING_RECORDTIME = "@RecordTime";
        private const string PARM_APROGRAMWRITING_USERID = "@UserID";
        private const string PARM_APROGRAMWRITING_PROGRAMFILES = "@ProgramFiles";
        #endregion

        #region 数据检索部分
        public IList<AProgramWritingInfo> LoadEntities()
        {
            return null;
        }

        /// <summary>
        /// Get an individual category based on a provided id
        /// </summary>
        /// <param name="categoryId">Category id</param>
        /// <returns>Details about the Category</returns>
        public AProgramWritingInfo LoadEntity<T1>(T1 sn)
        {
            return null;
        }

        public IList<AProgramWritingInfo> AProgramWriting_GetbySN(string sn)
        {
            SqlParameter parm = GetParameter();
            parm.Value = sn;
            return ExcuteSqlToGetEntities("AProgramWriting_selectbySN", parm);
        }

        public IList<AProgramWritingInfo> AProgramWriting_GetbyDT(DateTime dt1, DateTime dt2)
        {
            SqlParameter[] parms = GetDTParameters();
            parms[0].Value = dt1;
            parms[1].Value = dt2;
            return ExcuteSqlToGetEntities("AProgramWriting_selectbyDT", parms);
        }
        #endregion

        #region 重写基类部分
        public override AProgramWritingInfo GetEntityRecord(SqlDataReader rdr)
        {
            AProgramWritingInfo entity = new AProgramWritingInfo(rdr.GetValue(0).ToString(), rdr.GetDateTime(1), rdr.GetValue(2).ToString()
                , rdr.GetValue(3).ToString());
            return entity;
        }

        public override AProgramWritingInfo GetEntityRecord()
        {
            AProgramWritingInfo entity = new AProgramWritingInfo();
            return entity;
        }

        public override string GetInsertsp()
        {
            return "AProgramWriting_Insert";
        }

        public override string GetUpdatesp()
        {
            return null;
        }

        public override string GetDeletesp()
        {
            return null;
        }

        public override SqlParameter GetParameter()
        {
            return new SqlParameter(PARM_APROGRAMWRITING_PCBASN, SqlDbType.NVarChar, 50);
        }

        public override SqlParameter[] GetParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
					new SqlParameter(PARM_APROGRAMWRITING_PCBASN, SqlDbType.NVarChar, 50),
                    new SqlParameter(PARM_APROGRAMWRITING_RECORDTIME, SqlDbType.DateTime,8),
                    new SqlParameter(PARM_APROGRAMWRITING_USERID,SqlDbType.NVarChar,10),
					new SqlParameter(PARM_APROGRAMWRITING_PROGRAMFILES, SqlDbType.NVarChar, 50),
                };
            return parms;
        }

        public override void SetParameters(AProgramWritingInfo mo, params SqlParameter[] Parms)
        {
            Parms[0].Value = mo.PCBASN;
            Parms[1].Value = mo.RecordTime;
            Parms[2].Value = mo.UserID;
            Parms[3].Value = mo.ProgramFiles;
        }
        #endregion
    }
}
